package com.meowcook.mapper;

import com.meowcook.pojo.po.User;
import com.meowcook.pojo.vo.UserDetailVO;
import com.meowcook.pojo.vo.UserPartIVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 28792
 * Date: 2025-05-15
 * Time: 18:58
 */
@Mapper(componentModel = "spring")
public interface UserPojoMapper {
    UserPojoMapper INSTANCE = Mappers.getMapper(UserPojoMapper.class);

    @Mapping(source = "id", target = "id")
    @Mapping(source = "status", target = "status")
    User toPO(UserDetailVO userDetailVO);

    @Mapping(source = "id", target = "id")
    @Mapping(source = "nickname", target = "nickname")
    @Mapping(source = "avatarUrl", target = "avatarUrl")
    @Mapping(source = "isAdmin", target = "isAdmin")
    UserPartIVO toPartIVO(User user);

    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "nickname", target = "nickname"),
            @Mapping(source = "phoneNum", target = "phoneNum"),
            @Mapping(source = "email", target = "email"),
            @Mapping(source = "gender", target = "gender"),
            @Mapping(source = "recipeCount", target = "recipeCount"),
            @Mapping(source = "fansCount", target = "fansCount"),
            @Mapping(source = "followCount", target = "followCount"),
            @Mapping(source = "isAdmin", target = "isAdmin"),
            @Mapping(source = "bio", target = "bio"),
            @Mapping(source = "status", target = "status"),
            @Mapping(source = "avatarUrl", target = "avatarUrl"),
            @Mapping(source = "createTime", target = "createTime"),
    })

    UserDetailVO toDetailVO(User user);
}
